package iedcyt.acute.controller.listeners.authorMerge;

import iedcyt.acute.model.AuthorMergeModel;
import iedcyt.acute.view.AuthorMergeView;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

public class AuthorSelectionListener implements Listener {

	private AuthorMergeModel _model;
	private AuthorMergeView _view;
	
	public AuthorSelectionListener(AuthorMergeView view, AuthorMergeModel model) {
		this._model = model;
		this._view = view;
	}
	
	public void handleEvent(Event event) {
		Integer idAu = _view.getSelectedAuthorID();
		_model.setSelected_authorId(idAu);
		
		_view.loadCandidateAuthors(_model.getCandidates());
		_view.loadAuthorDocuments(_model.getAuthorDocs());
		_view.loadCandidateDocuments(_model.getCandidateDocs());
		_view.loadAuthorCenters(_model.getAuthorCenters(), _model.isAuthorCentersWarning());
		_view.loadCandidateCenters(_model.getCandidateCenters(),_model.isCandidatCentersWarning());
		_view.loadAuthorCorps(_model.getAuthorCorps(), _model.isAuthorCorpsWarning());
		_view.loadCandidateCorps(_model.getCandidateCorps(), _model.isCandidateCorpsWarning());
		_view.loadAuthorSigns(_model.getAuthorSigns());
		_view.loadCandidateSigns(_model.getCandidateSigns());
		_view.loadAuthorSignsCollaborators(_model.getAuthorCollSigns());
		_view.loadCandidateSignsCollaborators(_model.getCandidateCollSigns());
		_view.loadAuthorAuthorsCollaborators(_model.getAuthorCollAuthors());
		_view.loadCandidateAuthorsCollaborators(_model.getCandidateCollAuthors());

		_view.compareTables();
	}
}
